

package com.loong.loong.hik.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loong.loong.common.core.util.R;
import com.loong.loong.common.log.annotation.SysLog;
import com.loong.loong.hik.entity.FaceIdentifyResource;
import com.loong.loong.hik.service.FaceIdentifyResourceService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.loong.loong.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 人脸识别资源
 *
 * @author jinyiang
 * @date 2023-04-18 14:18:38
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/faceidentifyresource" )
@Api(value = "faceidentifyresource", tags = "人脸识别资源管理")
public class FaceIdentifyResourceController {

    private final  FaceIdentifyResourceService faceIdentifyResourceService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param faceIdentifyResource 人脸识别资源
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_view')" )
    public R getFaceIdentifyResourcePage(Page page, FaceIdentifyResource faceIdentifyResource) {
        return R.ok(faceIdentifyResourceService.page(page, Wrappers.query(faceIdentifyResource)));
    }


    /**
     * 通过id查询人脸识别资源
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(faceIdentifyResourceService.getById(id));
    }

    /**
     * 新增人脸识别资源
     * @param faceIdentifyResource 人脸识别资源
     * @return R
     */
    @ApiOperation(value = "新增人脸识别资源", notes = "新增人脸识别资源")
    @SysLog("新增人脸识别资源" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_add')" )
    public R save(@RequestBody FaceIdentifyResource faceIdentifyResource) {
        return R.ok(faceIdentifyResourceService.save(faceIdentifyResource));
    }

    /**
     * 修改人脸识别资源
     * @param faceIdentifyResource 人脸识别资源
     * @return R
     */
    @ApiOperation(value = "修改人脸识别资源", notes = "修改人脸识别资源")
    @SysLog("修改人脸识别资源" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_edit')" )
    public R updateById(@RequestBody FaceIdentifyResource faceIdentifyResource) {
        return R.ok(faceIdentifyResourceService.updateById(faceIdentifyResource));
    }

    /**
     * 通过id删除人脸识别资源
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除人脸识别资源", notes = "通过id删除人脸识别资源")
    @SysLog("通过id删除人脸识别资源" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(faceIdentifyResourceService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param faceIdentifyResource 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('hik_faceidentifyresource_export')" )
    public List<FaceIdentifyResource> export(FaceIdentifyResource faceIdentifyResource) {
        return faceIdentifyResourceService.list(Wrappers.query(faceIdentifyResource));
    }

	/**
	 * 查询list
	 * @param faceIdentifyResource 人脸识别资源
	 * @return
	 */
	@ApiOperation(value = "查询list", notes = "查询list")
	@GetMapping("/list" )
	public R getFaceIdentifyResourcePage( FaceIdentifyResource faceIdentifyResource) {
		return R.ok(faceIdentifyResourceService.list( Wrappers.query(faceIdentifyResource)));
	}
}
